﻿namespace CommLib
{
    public class MessageCalendar : BluetoothMessage
    {

        public MessageCalendar(byte[] data, int length)
            : base(BtMessageType.Calendar, data, length)
        {
        }

        public int getCalendarId()
        {
            return int.Parse(mData[0]);
        }

        public CalendarEntry[] getEntries()
        {
            CalendarEntry[] list = null;

            if ((mData.Length - 1) % CalendarEntry.FIELD_COUNT == 0)
            {
                list = new CalendarEntry[(mData.Length - 1) / CalendarEntry.FIELD_COUNT];

                int idx = 0;
                for (int i = 1; i < mData.Length; i += CalendarEntry.FIELD_COUNT)
                {
                    list[idx++] = new CalendarEntry(mData, i);
                }
            }

            return list;
        }
    }
}
